/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package filesTableModel;

import SessionBeans.web.beans.FileInfo;
import entities.FileChangeLog;
import entities.FolderChangeLog;
import entities.OperationType;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 *
 * @author Tomas
 */
public class Utils {

    public static String getChangeString(FileChangeLog changeLog) {

        return getStringFromDate(changeLog.getDate(), changeLog.getOperationType());
    }

    public static String getChangeString(FolderChangeLog changeLog) {
        return getStringFromDate(changeLog.getDate(), changeLog.getOperationType());
    }

    private static String getStringFromDate(Date date, OperationType operationType) {
        DateFormat dateFormat = new SimpleDateFormat("dd.MM.YYYY HH:mm");
        DateFormat dateOnly = new SimpleDateFormat("dd.MM.YYYY");
        DateFormat timeOnly = new SimpleDateFormat("H:m");

        String dateString;
        if (dateOnly.format(new Date()).equals(dateOnly.format(date))) {
            dateString = "Today " + timeOnly.format(date);
        } else {
            dateString = dateFormat.format(date);
        }
        return dateString + " " + operationType.getType();
    }

    public static String getSizeString(FileInfo fileInfo) {
        Long vel = fileInfo.getSize() / 1000;
        if (vel < 1) {
            vel = 1l;
        }
        return vel + " Kb";
    }
    
    public static String getRigthsText(int rightsLevel){
        
        return "";
    }
}
